﻿<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
    namespace="ProEnt.LoanPrequalification.Model.LoanApplications"
        assembly="ProEnt.LoanPrequalification.Model">

	<class name="ProEnt.LoanPrequalification.Model.LoanApplications.LoanApplication" table="LoanApplications" lazy="false">

		<id name="Id" column="LoanApplicationId" type="guid">
			<generator class="guid" />
		</id>

        <component access="field.camelcase-underscore" name="PropertyAddress" class="ProEnt.LoanPrequalification.Model.Address">
            <property access="field.camelcase-underscore" column="PropertyStreet" name="Street"/>
            <property access="field.camelcase-underscore" column="PropertyTown" name="Town"/>
            <property access="field.camelcase-underscore" column="PropertyCity" name="City"/>
            <property access="field.camelcase-underscore" column="PropertyPostCode" name="PostCode"/>
        </component>

        <component access="field.camelcase-underscore" name="Offer" class="Offer">
            <property access="field.camelcase-underscore" column="OfferInterestRate" name="InterestRate"/>
            <property access="field.camelcase-underscore" column="OfferAmount" name="LoanAmount"/>
            <property access="field.camelcase-underscore" column="OfferExpirationDate" name="ExpirationDate"/>
            <property access="field.camelcase-underscore" column="OfferTerm" name="LoanTerm"/>            
        </component>

        <property name="Deposit">
            <column name="Deposit" sql-type="integer" not-null="true" />
        </property>

        <property name="PropertyValue">
            <column name="PropertyValue" sql-type="integer" not-null="true" />
        </property>

        <property name="LoanAmount">
            <column name="LoanAmount" sql-type="integer" not-null="true" />
        </property>
        
        <property name="LoanTerm">
            <column name="LoanTerm" sql-type="integer" not-null="true" />
        </property>

        <property name="Status">
            <column name="Status" sql-type="integer" not-null="true" />
        </property>
        
        <many-to-one name="Product"
                     class="ProEnt.LoanPrequalification.Model.Products.Product"
                     column="ProductId"
                     cascade="none"
					 not-null="true"
					 />
             
        <bag name="Borrowers" table="LoanBorrowers" access="field.camelcase-underscore" 
             cascade="all" lazy="false" >
			    <key column="LoanApplicationId"/>			
			      <many-to-many  class="ProEnt.LoanPrequalification.Model.Borrowers.Borrower" column="BorrowerId"></many-to-many>
		    </bag>
   


    <bag name="Assets" access="field.camelcase-underscore" inverse="true" cascade="all" lazy="true" >
			<key column="LoanApplicationId"/>
			<one-to-many class="Asset"></one-to-many>
		</bag>

		<bag name="Debts" access="field.camelcase-underscore" inverse="true" cascade="all" lazy="true" >
			<key column="LoanApplicationId"/>
			<one-to-many class="Debt"></one-to-many>
		</bag>

	</class>

</hibernate-mapping>